﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordDocumentGenerator.Library;

namespace GPS.ENTITYS
{
    public class CrudModelITHHOCVIEN
    {
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public decimal? STT { get; set; }
        public string STT_ORDER_KH { get; set; }
        public string HV_MA { get; set; }
        public string HV_DVGTVT_MA { get; set; }
        public string HV_KH_MA { get; set; }
        public string KH_TEN { get; set; }
        public string HV_HANGDT_MA { get; set; }
        public string HV_HOTEN { get; set; }
        public string HV_GIOITINH { get; set; }
        public string HV_QUOCTICH_MA { get; set; }
        public string HV_NGAYSINH { get; set; }
        public string HV_NOITT { get; set; }
        public string HV_NOICT { get; set; }
        public string HV_SOCMT { get; set; }
        public DateTime? HV_NGAYCAPCMT { get; set; }
        public string HV_NOICAPCMT { get; set; }
        public string HV_MOTA { get; set; }
        public byte[] HV_HS_ANH { get; set; }
        public string HV_HS_SOHOSO { get; set; }
        public string HV_HS_HANGDT_MA_GPLXDACO { get; set; }
        public string HV_HS_TTXL_MA { get; set; }
        public string HV_HS_HOSO_MA { get; set; }
        public string HV_HS_DVGTVT_MA_NHANHS { get; set; }
        public string HV_HS_DONVICAPGPLXDACO { get; set; }
        public string HV_HS_SOGPLXDACO { get; set; }
        public string HV_HS_MAHTCAP { get; set; }
        public string HV_HS_HANGGPLXDACO { get; set; }
        public string HV_HS_NGAYCAPGPLXDACO { get; set; }
        public string HV_HS_NOICAPGPLXDACO { get; set; }
        public DateTime? HV_HS_NGAYINGIAYTN { get; set; }
        public string HV_HS_DVGTVT_MA_GPLXDACO { get; set; } 
    }

    public class EXPORTWORD_QLHV
    {
        public static byte[] EXPORT_QLHV(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<CrudModelITHHOCVIEN> docGenerator = new COMMON.ExportCore<CrudModelITHHOCVIEN>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }
}
